<!-- 友情链接模块 -->
<template>
  <div class="tFriendsBox">
    <div class="linkInfo">
      <el-row :gutter="24">
        <el-col :span="24">
          
          <el-card
            shadow="always"
            style="
              text-align: center;
              font-size: 25px;
              background-color: pink;
              color: white;
            "
          >
            友链展示~点击即可跳转
          </el-card>
        </el-col>
      </el-row>
    </div>

    <el-row>
      <el-col
        :span="12"
        class="tf-item"
        v-for="(item, index) in friendslink"
        :key="'f' + index"
      >
        <el-skeleton
          :loading="isLoading"
          animated
          :rows="3"
          style="width: 100%"
        >
          <a :href="item.address" target="_blank">
            <!-- 骨架屏模板内容 -->
            <img
              :src="item.logo ? item.logo : ''"
              :onerror="$store.state.errorImg"
            />
            <h4>{{ item.name }}</h4>
            <p>{{ item.description }}</p>
          </a>
        </el-skeleton>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { getAllLink } from "../api/link.js";
export default {
  data() {
    //选项 / 数据
    return {
      isLoading: true,
      friendslink: [], //友情链接
    };
  },
  methods: {
    //事件处理器
    getList() {
      getAllLink().then((response) => {
        this.friendslink = response;

        // 延迟一秒后关闭 Loading
        setTimeout(() => {
          this.isLoading = false;
        }, 2000);
      });
    },
  },
  components: {
    //定义组件
  },
  created() {
    //生命周期函数
    this.getList();
  },
};
</script>

<style>
.tFriendsBox {
  background: rgb(255, 255, 255);
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 40px;
}
.tFriendsBox .tf-item {
  display: inline-block;
  vertical-align: middle;
  -webkit-transform: perspective(1px) translateZ(0);
  transform: perspective(1px) translateZ(0);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0);
  position: relative;
  -webkit-transition-property: color;
  transition-property: color;
  -webkit-transition-duration: 0.3s;
  transition-duration: 0.3s;
}
.tFriendsBox .tf-item::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: pink;
  -webkit-transform: scaleX(0);
  transform: scaleX(0);
  -webkit-transform-origin: 0 50%;
  transform-origin: 0 50%;
  -webkit-transition-property: transform;
  transition-property: transform;
  -webkit-transition-duration: 0.5s;
  transition-duration: 0.5s;
  -webkit-transition-timing-function: ease-out;
  transition-timing-function: ease-out;
}
.tFriendsBox .tf-item:hover:before,
.tFriendsBox .tf-item:focus:before,
.tFriendsBox .tf-item:active:before {
  -webkit-transform: scaleX(1);
  transform: scaleX(1);
}
.tFriendsBox h1 {
  padding: 15px 0;
  font-size: 25px;
  font-weight: bold;
}
.tFriendsBox .tf-item {
  width: 48%;
  transition: all 0.3s ease-out;
  border-radius: 5px;
  position: relative;
  margin: 15px 5px 15px 5px;
  border: 1px rgb(243, 240, 240) solid;
  box-shadow: 0 0 20px rgba(46, 45, 45, 0.267); /* 添加阴影效果 */
}
@media screen and (max-width: 768px) {
  /* 当屏幕宽度小于等于 768px 时执行以下 CSS 代码 */
  .tFriendsBox .tf-item {
    width: 100%; /* 将元素宽度设置为 100% */
    margin-left: 0; /* 取消左侧的 margin */
    margin-right: 0; /* 取消右侧的 margin */
  }
}

.tFriendsBox .tf-item:hover {
  background: rgba(205, 208, 209, 0.5);
}
.tFriendsBox .tf-item a {
  display: block;
  padding: 0 10px 0 90px;
  height: 90px;
}
.tFriendsBox .tf-item a img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  position: absolute;
  top: 15px;
  left: 15px;
  cursor: pointer;
  object-fit: cover;
}
.tFriendsBox .tf-item a h4 {
  cursor: pointer;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  font-size: 20px;
  padding-top: 15px;
  font-weight: bold;
}
.tFriendsBox .tf-item a p {
  margin: 10px 0;
  font-size: 12px;
  line-height: 24px;
  color: #999;
  cursor: pointer;
  white-space: nowrap;
  text-overflow: ellipsis;
}
</style>
